// 父
import { useState } from 'react'

import "../表单/todolist.css";
import Search from "./Search";
import List from "./list";

const Todolist3 =()=>{

  const [list, setuser] = useState({
    list:[
        {
          time:'2003-2-8',
          name:"王喜跃",
          priority:1
        },
        {
          time:'2003-2-8',
          name:"赵帅",
          priority:2
        }
      ]
    
  })

  let todolist3 =(msg)=>{
    console.log(msg);
    let nlist = list.list //把数据重新付个变量
    nlist.push(msg)       //把传过来的数据push给初始数据
    setuser(()=>{         //改变原数据
      return{
      ...list,
      list:nlist
      }
    })

  }

  return (
    <>
      <div className="todolist3">
       <Search todolist3={todolist3}></Search><hr />
       <List list={list}></List>
      </div>
    </>
  )
}

export default Todolist3;